package org.sixtynine.stock.service.impl;

import java.util.Date;
import java.util.List;

import org.sixtynine.stock.dao.WeeklyShareDataDao;
import org.sixtynine.stock.dto.GridPramDTO;
import org.sixtynine.stock.dto.Page;
import org.sixtynine.stock.entity.WeeklyShareData;
import org.sixtynine.stock.service.WeeklyShareDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author Thilan
 * 
 */
@Service
public class WeeklyShareDataServiceImpl implements WeeklyShareDataService {

	@Autowired
	private WeeklyShareDataDao weeklyShareDataDao;

	@Override
	public void saveWeeklyShareData(WeeklyShareData weeklyShareData) {
		weeklyShareDataDao.saveWeeklyShareData(weeklyShareData);

	}

	@Override
	public void deleteWeeklyShareData(int id) {
		WeeklyShareData weeklyShareData = weeklyShareDataDao.findById(id);
		if (weeklyShareData != null) {
			weeklyShareDataDao.delete(weeklyShareData);
		}
	}

	@Override
	public List<WeeklyShareData> findWeeklyShareData(int id) {
		return weeklyShareDataDao.findWeeklyShareData(id);
	}

	@Override
	public List<WeeklyShareData> searchWeeklyShareData(int companyId,
			Date fromDate, Date toDate, String orderBy, String orderByName) {
		return weeklyShareDataDao.searchWeeklyShareData(companyId, fromDate,
				toDate, orderBy, orderByName);
	}

	@Override
	public Page<WeeklyShareData> searchWeeklyShareData(int companyId,
			Date fromDate, Date toDate, String orderBy, String orderByName,
			GridPramDTO gridPramDTO) {
		return weeklyShareDataDao.searchWeeklyShareData(companyId, fromDate,
				toDate, orderBy, orderByName, gridPramDTO);
	}

	@Override
	public WeeklyShareData findById(int id) {
		return weeklyShareDataDao.findById(id);
	}

	@Override
	public void deleteWeeklyShareData(int companyId, Date fromDate, Date toDate) {
		weeklyShareDataDao.deleteWeeklyShareData(companyId, fromDate, toDate);
	}

}
